import {solutionMethod} from '@/utils/models/solution.js'
const crudMethod = new solutionMethod();
import Footer from '@/components/footer-main'
import { tableDicts} from "@/utils/common";

export default {
  name: 'Home',
  components: { Footer},
  data() {
    return {
      query: {
        solutionId: null,
        type: 0,
      },
      solutionFrameTitle: '',
      solutionSceneTitle: '',
      solutionName: '',
      loading: false,
      loading0: false,
      preview: [],
      preview0: [],
      curId: null,
      curIds: null,
      solutionImg: '',
      solutionSlogan: '',
      typeData: [ // 框架说明明细类型
        { value: '2', label: '技术框架'},
        { value: '1', label: '业务框架'}
      ],
      typeData0: [ // 场景介绍明细类型
        { value: '2', label: '运输时效'},
        { value: '1', label: '车辆职能管理'}
      ]
    }
  },
  created() {
    this.query.solutionId = this.$route.query.id
    this.getSolutions()
    this.getDetails()
    this.getDetails0()
    this.frontCmfSolution()
  },
  methods: {
    tableDicts,
    goDetails(link) {
      this.query.solutionId = link.solutionId
      this.getSolutions()
      this.getDetails()
      this.getDetails0()
      this.frontCmfSolution()
    },
    /**访问次数**/
    frontCmfSolution() {
      let _this = this
      let params = {
        solutionId: _this.query.solutionId
      }
      crudMethod.frontCmfSolution(params).then((res) => {
      })
    },
    // 解决方案
    getSolutions () {
      let _this = this
      crudMethod.getSolution().then((res) => {
        let {msg, code, data} = res;
        for(let i in data.data) {
          let item = data.data[i]
          if(_this.query.solutionId == item.solutionId) {
            document.title = item.solutionName
            _this.solutionFrameTitle = item.solutionFrameTitle
            _this.solutionName = item.solutionName
            _this.solutionSceneTitle = item.solutionSceneTitle
            _this.solutionSlogan = item.solutionSlogan
            _this.solutionImg = _this.baseURL + item.solutionImg
            console.log(_this.solutionImg)
            break
          }
        }
      })
    },
    // 框架说明
    getDetails() {
      let _this = this
      _this.loading = true
      let params = {
        solutionId: _this.query.solutionId,
        type: 0,
      }
      crudMethod.getDetail(params).then((res) => {
        _this.loading = false
        let {msg, code, data} = res;
        _this.preview = data.data
        _this.curId = _this.preview[0].introduceId
      })
    },
    // 场景介绍
    getDetails0() {
      let _this = this
      _this.loading0 = true
      let params = {
        solutionId: _this.query.solutionId,
        type: 1,
      }
      crudMethod.getDetail(params).then((res) => {
        _this.loading0 = false
        let {msg, code, data} = res;
        _this.preview0 = data.data
        _this.curIds = _this.preview0[0].introduceId
      })
    },
    handleTabs(val) {
      this.curId = val
    },
    handleTabs0(val) {
      this.curIds = val
    }
  }
}
